package cn.com.infcn.monitor.task.system;

import org.apache.log4j.Logger;
import org.hyperic.sigar.OperatingSystem;
import org.hyperic.sigar.SigarException;

import cn.com.infcn.monitor.bean.IFCOperatingSystem;
import cn.com.infcn.monitor.task.BaseTask;
import cn.com.infcn.monitor.util.IFCBeanUtils;

/**
 * 获取操作系统相关信息
 * 
 * @author jjs
 *
 */
public class OsTask implements BaseTask {

	private static final Logger LOGGER = Logger.getLogger(OsTask.class);

	@Override
	public IFCOperatingSystem execute() throws Exception {
		return os();
	}

	private IFCOperatingSystem os() throws SigarException {

		try {
			OperatingSystem os = OperatingSystem.getInstance();
			IFCOperatingSystem operatingSystem = new IFCOperatingSystem();
			IFCBeanUtils.copyProperties(os, operatingSystem);

			return operatingSystem;
		} catch (Exception e) {
			LOGGER.warn(e.getMessage(), e);
		}
		return null;
	}

	/*private void copyProperties(OperatingSystem os, IFCOperatingSystem operatingSystem){
		operatingSystem.setArch(os.getArch());
		operatingSystem.setCpuEndian(os.getCpuEndian());
		operatingSystem.setDataModel(os.getDataModel());
		operatingSystem.setDescription(os.getDescription());
		operatingSystem.setMachine(os.getMachine());
		operatingSystem.setName(os.getName());
		operatingSystem.setPatchLevel(os.getPatchLevel());
		operatingSystem.setVendor(os.getVendor());
		operatingSystem.setVendorCodeName(os.getVendorCodeName());
		operatingSystem.setVendorName(os.getVendorName());
		operatingSystem.setVendorVersion(os.getVendorVersion());
		operatingSystem.setVersion(os.getVersion());
	}*/
}
